package com.dingli.admin.controller;

import com.dingli.admin.service.IBankService;
import com.dingli.framework.entity.Bank;
import com.dingli.framework.util.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin("*")
@RestController
@RequestMapping("/bank")
@Api(tags = "银行管理")
public class BankController {
    @Autowired
    private IBankService iBankService;

    @GetMapping("/allBank")
    @ApiOperation("银行信息查询所有")
    public Response<List<Bank>> allBank() {
        return iBankService.allBank();
    }

    @GetMapping("/list")
    @ApiOperation("银行信息列表查询")
    public Response<List<Bank>> list(@ApiParam("条件") @RequestParam(required =
            false) String search) {
        return iBankService.list(search);
    }

    @PostMapping("/insert")
    @ApiOperation("银行信息新增")
    public Response<Long> insert(@RequestBody Bank bank) {
        return iBankService.insert(bank);
    }

    @PostMapping("/updateById")
    @ApiOperation("银行信息修改")
    public Response<Object> updateById(@RequestBody Bank bank) {
        return iBankService.updateById(bank);
    }

    @GetMapping("/deleteById")
    @ApiOperation("指定银行信息删除")
    public Response<Object> deleteById(@ApiParam("银行ID") @RequestParam Long
                                               bankId) {
        return iBankService.deleteById(bankId);
    }


    @PostMapping("/deleteBatch")
    @ApiOperation("银行信息批量删除")
    public Response<Object> deleteBatch(@ApiParam("银行ID集合") @RequestBody
                                                List<Long> idList) {
        return iBankService.deleteBatch(idList);
    }



}